﻿using System;
using System . Collections . Generic;
using System . IO;
using System . Linq;
using System . Runtime . InteropServices . WindowsRuntime;
using Windows . Foundation;
using Windows . Foundation . Collections;
using Windows . UI;
using Windows . UI . Xaml;
using Windows . UI . Xaml . Controls;
using Windows . UI . ViewManagement;
using Windows . UI . Xaml . Media . Animation;
using Windows . UI . Xaml . Controls . Primitives;
using Windows . UI . Xaml . Data;
using Windows . UI . Xaml . Input;
using Windows . UI . Xaml . Media;
using Windows . UI . Xaml . Navigation;
using WenceyWang . RichMan4L;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace WenceyWang . RichMan4L . App . Pages
{

    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage ( )
        {
            this . InitializeComponent ( );

            this . NavigationCacheMode = NavigationCacheMode . Required;
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo ( NavigationEventArgs e )
        {

            // TODO: Prepare page for display here.

            // TODO: If your application contains multiple pages, ensure that you are
            // handling the hardware Back button by registering for the
            // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
            // If you are using the NavigationHelper provided by some templates,
            // this event is handled for you.
            //Windows.Phone.UI.Input.HardwareButtons.
        }

        private void page_Loaded ( object sender , RoutedEventArgs e )
        {
            StartStoryBoard . Begin ( );
        }

        private void NewGameButton_Click ( object sender , RoutedEventArgs e )
        {

            EasyPage . Navigate ( typeof ( CreateGamePage ) , new StartGameParameters ( ) , "Lime" , LeaveStoryBoard , BackGroundRect , Frame , RemoveControl , AddControl );
        }
        private void SettingButton_Click ( object sender , RoutedEventArgs e )
        {
            EasyPage . Navigate ( typeof ( SettingPage ) , null , "DeepRed" , LeaveStoryBoard , BackGroundRect , Frame , RemoveControl , AddControl );
        }

        private void RemoveControl ( )
        {
            NewGameButton . Click -= NewGameButton_Click;
            SettingButton . Click -= SettingButton_Click;
        }

        private void AddControl ( )
        {
            NewGameButton . Click += NewGameButton_Click;
            SettingButton . Click += SettingButton_Click;
        }

        private void page_Unloaded ( object sender , RoutedEventArgs e )
        {

        }

        private void LoadGameButton_Click ( object sender , RoutedEventArgs e )
        {
            EasyPage . Navigate ( typeof ( LoadGamePage ) , null , "Black" , LeaveStoryBoard , BackGroundRect , Frame , RemoveControl , AddControl );
        }
    }
}
